import { DefaultStage } from "../default-stage";
import { GradientSkybox } from 'babylon-lib/preset/gradient-skybox';
import { DefaultModel } from "./default-model";
import { ModelContainer } from "./model-container";


class GenerateComponent {

    public static initialize(stage: DefaultStage): void {
        ModelContainer.initialize(stage);
        DefaultModel.initialize(stage);
        this.setBackground(stage);
    }

    public static rebuild(stage: DefaultStage): void {
        this.setBackground(stage);
    }

    private static setBackground(stage: DefaultStage): void {
        const sky = new GradientSkybox('sky', stage.mainScene, {
            values: [0.2, 0.5, 0.8],
            colors: ['#ffffff', '#00375c', '#52baff'],
            size: 1900,
        });

        stage.mainScene.onBeforeRenderObservable.add(() => {
            const cam = stage.mainCamera;
            sky.mesh.position.copyFrom(cam.globalPosition);
        });
    }

}


export { GenerateComponent };